// 220127 2027
// child_process.spawn
// 需要同目录下的 support.js

const fs = require('fs');
const child_process = require('child_process');

for (var i=0; i<3; i++) {
	// 需要使用 __dirname
	var workerProcess = child_process.spawn('node', [__dirname + '/support.js', i]);
	
	workerProcess.stdout.on('data', function(data) {
		console.log('stdout: ' + data);
	});
	
	workerProcess.stderr.on('data', function(data) {
		console.log('stderr: ' + data);
	});
	
	workerProcess.on('close', function(code) {
		console.log('子进程已退出，退出码 '+code);
	});
}
